package com.nbgs.demo.dao;

import com.nbgs.demo.controller.form.InsertConsumptionInfoForm;
import com.nbgs.demo.info.StageInfo;
import com.nbgs.demo.model.WaterBill;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface InsertConsumptionInfoMapper {
    @Insert("insert into t_waterbill(consumption_id,consumption_volume,payable,card_id,bill_generate_time) " +
            "values (#{consumptionId},#{consumptionVolume},#{payable},#{cardId},#{billGenerateTime})")
    void insertInfo(WaterBill waterBill);

    @Select("select card_id from t_card where card_num = #{cardNum}")
    int selectCardId(String cardNum);

    @Update("update t_consumption set consumption_end = #{consumptionEnd}," +
            "entry_date = #{entryDate},consumption_state = 'true', " +
            "worker_name = #{workerName} where " +
            "consumption_id = #{consumptionId}")
    void  insertConsumptionInfo(InsertConsumptionInfoForm insertConsumptionInfoForm);


    @Select("select stage_id,stage_scope from t_stage_scope " +
            "join t_type on t_type.type_id = t_stage_scope.type_id " +
            "where t_type.type =#{type} " +
            "order by stage_scope ASC")
    List<StageInfo> selectAllScopeInfo(String type);


    @Select("select price from t_water_price join t_stage_scope  " +
            "on t_water_price.stage_id = t_stage_scope.stage_id  " +
            "where t_stage_scope.stage_id = #{stageId}")
    double selectCurrentScopeWaterPrice(int stageId);
}
